#include <string>

/*
模板方法模式：先写公共抽象类作为模板类（包含该类的公共方法和属性，差异方法标为纯虚函数在各实现类中重写），再写实现类。
*/

class Worker{
private:
    std::string name;

public:
    Worker(std::string s) : name(s) {}
    virtual ~Worker() {}

    virtual void work() = 0;
    virtual bool isNeedTimestamp(){
        return false;
    }

    void workOneDay(){
        entryCompany();
        work();
        exitCompany();
    }

private:
    void entryCompany(){
        printf("%s entry company.\n", name.c_str());
    }
    void exitCompany(){
        if(isNeedTimestamp()){
            printf("%d ", time(nullptr));
        }
        printf("%s exit company.\n", name.c_str());
    }
};

class IT : public Worker{
public:
    IT(std::string s) : Worker(s) {}

    void work(){
        printf("Coding, haha, dring ...\n");
    }
};

class HR : public Worker{
public:
    HR(std::string s) : Worker(s) {}

    void work(){
        printf("haha, dring ...\n");
    }

    bool isNeedTimestamp(){
        return true;
    }
};

class QA : public Worker{
public:
    QA(std::string s) : Worker(s) {}

    void work(){
        printf("testting, haha, dring ...\n");
    }
};